package com.yanqu.road.dao.impl.activity.fanxiuspring;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.activity.fanxiuspring.FanXiuSpringDrawInfo;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class FanXiuSpringConfigDaoImpl extends TempDao {

    private static String getFanXiuSpringDrawInfoSql = "select * from `t_s_activity_xiuxian_new_draw` where `activityId`=? ORDER BY `id` ASC";
    public List<FanXiuSpringDrawInfo> getFanXiuSpringDrawInfoList(int activityId) {
        List<FanXiuSpringDrawInfo> list = new ArrayList<>();
        ResultSet rs = null;
        CallableStatement call = null;
        try {
            getDb().setConnName(DbNameStrategy.getServerDb());
            call = getDb().getConnection().prepareCall(getFanXiuSpringDrawInfoSql);
            call.setInt(1, activityId);
            rs = call.executeQuery();
            while (rs.next()) {
                FanXiuSpringDrawInfo data = new FanXiuSpringDrawInfo();
                data.setActivityId(rs.getInt("activityId"));
                data.setId(rs.getInt("id"));
                data.setReward(rs.getString("reward"));
                data.setWeight(rs.getInt("weight"));
                data.setLv(rs.getInt("lv"));
                data.setIsNotice(rs.getInt("isNotice"));
                list.add(data);
            }
        } catch (Exception e) {
            logger.error(Thread.currentThread().getStackTrace()[1].getMethodName() + ":", e);
        } finally {
            getDb().closeConnection(call, rs);
        }
        return list;
    }




}
